<% layout('/layout/default.html', {title: '区域管理', libs: ['dataGrid']}){ %>
<div class="main-content">
		<div class="card-header">
				<i class="fa fa-sitemap"></i> 区域管理
			<div class="header-tools float-right">
				<a href="#" class="btn btn-sm btn-secondary"  id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
				<a href="#" class="btn btn-sm btn-secondary" id="btnExpandTreeNode" title="展开一级"><i class="fa fa-angle-double-down"></i> 展开</a>
				<a href="#" class="btn btn-sm btn-secondary" id="btnCollapseTreeNode" title="折叠全部"><i class="fa fa-angle-double-up"></i> 折叠</a>
				<% if(hasPermi('sys:area:edit')){ %>
					<a href="/sys/area/form" class="btn btn-sm btn-secondary btnTool" title="添加根区域"><i class="fa fa-plus"></i> 添加根区域</a>
				<% } %>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/sys/area/listData" class="form-inline d-none">
				<button type="submit" class="btn btn-primary">查询</button>
				<button type="reset" class="btn btn-secondary">重置</button>
			</form>
			<table id="btGrid"></table>
		</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
	$('#btGrid').BTGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{title:'区域名称', field:'name', align:"left"},
			{title:'区域编码', field:'code', align:"center"},
			{title:'区域类型', field:'type', align:"center", formatter: function(val, row, index){
                    return js.transDictLabel(${@DictUtils.getDictListJson('sys_area_type')}, val, '');
			}},
			{title:'排序', field:'sort', align:"center"},
			{title:'备注', field:'remarks', align:"center"},
			{title:'操作', field:'actions', align:"center", formatter: function(val, row, index){
				var actions = [];
				<% if(hasPermi('sys:area:edit')){ %>
                    actions.push('<a href="/sys/area/form?parentId='+row.id+'" class="btn btn-sm btn-success btnList" title="添加下级区域"><i class="fa fa-plus-square"></i></a>&nbsp&nbsp');
					actions.push('<a href="/sys/area/form?id='+row.id+'" class="btn btn-sm btn-primary btnList" title="修改区域信息"><i class="fa fa-pencil"></i></a>&nbsp&nbsp');
					actions.push('<a href="${ctx}/sys/area/delete?id='+row.id+'" class="btn btn-sm btn-danger btnList" title="删除区域" data-confirm="要删除该区域及所有子区域项吗？"><i class="fa fa-trash-o"></i></a>');

				<% } %>
				return actions.join('');
			}}
		],
        idField: 'id',
        treeShowField: 'name',
        parentIdField: 'pid',
        treeEnable: true,
        rootParentId: '0',
		treeIcons : {
			plus: "ui-icon-circlesmall-plus",
			minus: "ui-icon-circlesmall-minus",
			leaf : "ui-icon-document"
		},
		// 加载成功后执行事件
		ajaxSuccess: function(data){
			
		}
	});
</script>